scoreboard players tag @p add ZHSTemp
scoreboard players set @a[tag=ZHSTemp] ZHS 0
scoreboard players add @a[tag=ZHSTemp] book 0
scoreboard players add @a[tag=ZHSTemp,score_book=0] ZHS 1
scoreboard players add @a[tag=ZHSTemp,score_book_min=1] ZHS 1
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ tellraw @a {"text":"[召唤术调试报告] book记分项缺失！"}
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard objectives add book trigger
scoreboard players tag @p[tag=ZHSTemp,score_ZHS=0] add ZHSErr
scoreboard players set @a[tag=ZHSTemp] ZHS 0
execute @e[type=armor_stand,name=ZHS] ~ ~ ~ scoreboard players add @a[tag=ZHSTemp] ZHS 1
execute @e[type=armor_stand,name=ZHSTimer] ~ ~ ~ scoreboard players add @a[tag=ZHSTemp] ZHS 1
execute @e[type=armor_stand,name=ZHSPlayerCount] ~ ~ ~ scoreboard players add @a[tag=ZHSTemp] ZHS 1
scoreboard players set @a[tag=ZHSTemp,score_ZHS=2] ZHS 0
scoreboard players set @a[tag=ZHSTemp,score_ZHS_min=4] ZHS 0
scoreboard players tag @p[tag=ZHSTemp,score_ZHS=-1] add ZHSErr
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ tellraw @a {"text":"[召唤术调试报告] 盔甲架缺失！"}
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ kill @e[type=armor_stand,name=ZHS]
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ kill @e[type=armor_stand,name=ZHSTimer]
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ kill @e[type=armor_stand,name=ZHSPlayerCount]
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ summon armor_stand ~ ~1 ~ {CustomName:"ZHS",NoGravity:1b,Invisible:1,Marker:1}
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ summon armor_stand ~ ~1 ~ {CustomName:"ZHSTimer",NoGravity:1b,Invisible:1,Marker:1}
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ summon armor_stand ~ ~1 ~ {CustomName:"ZHSPlayerCount",NoGravity:1b,Invisible:1,Marker:1}
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHS] ZHS 0
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHSTimer] ZHS -1
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHSPlayerCount] ZHS 0
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard objectives remove ZHSSender
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard objectives remove ZHSHandler
execute @p[tag=ZHSTemp,score_ZHS=0] ~ ~ ~ scoreboard objectives remove ZHSPlayers
scoreboard players tag @a[tag=ZHSTemp] remove ZHSTemp
execute @p[tag=ZHSErr] ~ ~ ~ tellraw @a [{"text":"[召唤术调试报告] 异常处理完毕！ 输入 "},{"text":"/trigger book set 6","color":"yellow","underlined":true,"clickEvent":{"action":"run_command","value":"/trigger book set 6"}},{"text":" 使用召唤术吧！"}]
scoreboard players tag @a[tag=ZHSErr] remove ZHSErr
teleport @e[type=armor_stand,name=ZHS] ~ ~ ~
teleport @e[type=armor_stand,name=ZHSTimer] ~ ~ ~
teleport @e[type=armor_stand,name=ZHSPlayerCount] ~ ~ ~
scoreboard players enable @a book
scoreboard players remove @e[type=armor_stand,name=ZHSTimer,score_ZHS_min=0] ZHS 1
execute @e[type=armor_stand,name=ZHSTimer,score_ZHS=0,score_ZHS_min=0] ~ ~ ~ scoreboard objectives remove ZHSSender
execute @e[type=armor_stand,name=ZHSTimer,score_ZHS=0,score_ZHS_min=0] ~ ~ ~ scoreboard objectives remove ZHSHandler
execute @e[type=armor_stand,name=ZHSTimer,score_ZHS=0,score_ZHS_min=0] ~ ~ ~ scoreboard objectives remove ZHSPlayers
execute @e[type=armor_stand,name=ZHSTimer,score_ZHS=0,score_ZHS_min=0] ~ ~ ~ tellraw @a [{"text":"『召唤』 ","color":"light_purple"},{"text":"召唤术关闭！","color":"gray"}]
execute @e[type=armor_stand,name=ZHSTimer,score_ZHS=0,score_ZHS_min=0] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHS,score_ZHS_min=1] ZHS 0
execute @e[type=armor_stand,name=ZHS,score_ZHS_min=1] ~ ~ ~ tellraw @a[score_book=6,score_book_min=6] [{"text":"『召唤』 ","color":"light_purple"},{"text":"有人正在使用召唤术，请稍后！","color":"gray"}]
execute @e[type=armor_stand,name=ZHS,score_ZHS_min=1] ~ ~ ~ scoreboard players set @a[score_book=6,score_book_min=6] book 0
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHSPlayerCount] ZHS 0
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ stats entity @e[type=armor_stand,name=ZHSPlayerCount] set AffectedEntities @e[type=armor_stand,name=ZHSPlayerCount] ZHS
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount] ~ ~ ~ testfor @a
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ stats entity @e[type=armor_stand,name=ZHSPlayerCount] clear AffectedEntities
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS=1] ~ ~ ~ tellraw @p[score_book=6,score_book_min=6] [{"text":"『召唤』 ","color":"light_purple"},{"text":"使用失败！ ","color":"gray"},{"text":" [ 孤独的朋友啊，你想召唤谁呢？ ]","color":"dark_gray"}]
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS=1] ~ ~ ~ scoreboard players set @p[score_book=6,score_book_min=6] book 0
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ tellraw @p[score_book=6,score_book_min=6] [{"text":"『召唤』 ","color":"light_purple"},{"text":"使用成功！ ","color":"gray"},{"text":" [ 请等待其他玩家向你发送传送请求 ]","color":"dark_gray"}]
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard objectives add ZHSSender trigger
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard objectives add ZHSHandler trigger
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard objectives add ZHSPlayers dummy
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard players set @a ZHSPlayers 0
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard players set @p[score_book=6,score_book_min=6] ZHSPlayers 4
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_book=6,score_book_min=6] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard players set @p[score_book=6,score_book_min=6] book 0
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_ZHSPlayers_min=4] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard players enable @a[score_ZHSPlayers=0] ZHSSender
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_ZHSPlayers_min=4] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ tellraw @a[score_ZHSPlayers=0] [{"text":"『召唤』 ","color":"light_purple"},{"selector":"@p[score_ZHSPlayers_min=4]"},{"text":"开启了召唤术！请在30秒内向Ta ","color":"dark_aqua"},{"text":"〖","color":"yellow"},{"text":"发送传送请求","underlined":true,"color":"yellow","clickEvent":{"action":"run_command","value":"/trigger ZHSSender set 1"}},{"text":"〗","color":"yellow"},{"text":"吧！","color":"dark_aqua"}]
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_ZHSPlayers_min=4] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHSTimer] ZHS 600
execute @e[type=armor_stand,name=ZHS,score_ZHS=0] ~ ~ ~ execute @p[score_ZHSPlayers_min=4] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=2] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHS,score_ZHS=0] ZHS 1
tellraw @a[score_ZHSSender_min=1] [{"text":"『召唤』 ","color":"light_purple"},{"text":"请求已发送，请等待对方处理……","color":"gray"}]
scoreboard players set @a[score_ZHSSender_min=1] ZHSPlayers 1
scoreboard players set @a[score_ZHSSender_min=1] ZHSSender 0
execute @p[score_ZHSPlayers=1,score_ZHSPlayers_min=1] ~ ~ ~ execute @p[score_ZHSPlayers=4,score_ZHSPlayers_min=4] ~ ~ ~ scoreboard players set @r[score_ZHSPlayers=1,score_ZHSPlayers_min=1] ZHSPlayers 2
execute @p[score_ZHSPlayers=2,score_ZHSPlayers_min=2] ~ ~ ~ execute @p[score_ZHSPlayers=4,score_ZHSPlayers_min=4] ~ ~ ~ tellraw @p[score_ZHSPlayers_min=4] [{"text":"『召唤』 ","color":"light_purple"},{"selector":"@p[score_ZHSPlayers=2,score_ZHSPlayers_min=2]"},{"text":"向你发出传送请求 ","color":"dark_aqua"},{"text":"〖","color":"green"},{"text":"同意","underlined":true,"color":"green","clickEvent":{"action":"run_command","value":"/trigger ZHSHandler set 1"}},{"text":"〗","color":"green"},{"text":" or ","color":"dark_aqua"},{"text":"〖","color":"red"},{"text":"拒绝","underlined":true,"color":"red","clickEvent":{"action":"run_command","value":"/trigger ZHSHandler set 2"}},{"text":"〗","color":"red"}]
execute @p[score_ZHSPlayers=2,score_ZHSPlayers_min=2] ~ ~ ~ execute @p[score_ZHSPlayers=4,score_ZHSPlayers_min=4] ~ ~ ~ scoreboard players enable @p[score_ZHSPlayers_min=4] ZHSHandler
execute @p[score_ZHSPlayers=2,score_ZHSPlayers_min=2] ~ ~ ~ execute @p[score_ZHSPlayers=4,score_ZHSPlayers_min=4] ~ ~ ~ scoreboard players set @p[score_ZHSPlayers=4,score_ZHSPlayers_min=4] ZHSPlayers 5
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler_min=2] ~ ~ ~ tellraw @s [{"text":"[ 你拒绝了来自 ","color":"dark_gray"},{"selector":"@p[score_ZHSPlayers=2,score_ZHSPlayers_min=2]"},{"text":" 的传送请求 ]","color":"dark_gray"}]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler_min=2] ~ ~ ~ tellraw @p[score_ZHSPlayers_min=2,score_ZHSPlayers=2] [{"text":"『召唤』 ","color":"light_purple"},{"text":"对方拒绝了你的传送请求，并向你丢出了一只暗夜。","color":"gray"}]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler_min=2] ~ ~ ~ scoreboard players set @p[score_ZHSPlayers_min=2,score_ZHSPlayers=2] ZHSPlayers 3
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=ZHSPlayerCount] ZHS 0
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ stats entity @e[type=armor_stand,name=ZHSPlayerCount] set AffectedEntities @e[type=armor_stand,name=ZHSPlayerCount] ZHS
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount] ~ ~ ~ testfor @e[type=player,score_ZHSPlayers_min=2,score_ZHSPlayers=2]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ stats entity @e[type=armor_stand,name=ZHSPlayerCount] clear AffectedEntities
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS=0] ~ ~ ~ tellraw @p[score_ZHSPlayers_min=5] {"text":"[ 被传送玩家意外死亡或离线 ]","color":"gray"}
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS=0] ~ ~ ~ tellraw @a[score_ZHSPlayers_min=2,score_ZHSPlayers=2] [{"text":"『召唤』 ","color":"light_purple"},{"text":"你已死亡，传送失败！","color":"gray"}]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS=0] ~ ~ ~ scoreboard players set @a[score_ZHSPlayers_min=2,score_ZHSPlayers=2] ZHSPlayers 3
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=1] ~ ~ ~ tp @p[score_ZHSPlayers_min=2,score_ZHSPlayers=2] @p[score_ZHSPlayers_min=5]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=1] ~ ~ ~ tellraw @p[score_ZHSPlayers_min=2,score_ZHSPlayers=2] [{"text":"『召唤』 ","color":"light_purple"},{"text":"传送成功！","color":"gray"}]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=1] ~ ~ ~ tellraw @p[score_ZHSPlayers_min=5] [{"text":"[ 你同意了来自 ","color":"dark_gray"},{"selector":"@p[score_ZHSPlayers=2,score_ZHSPlayers_min=2]"},{"text":" 的传送请求，传送成功 ]","color":"dark_gray"}]
execute @p[score_ZHSPlayers_min=5,score_ZHSHandler=1,score_ZHSHandler_min=1] ~ ~ ~ execute @e[type=armor_stand,name=ZHSPlayerCount,score_ZHS_min=1] ~ ~ ~ scoreboard players set @a[score_ZHSPlayers_min=2,score_ZHSPlayers=2] ZHSPlayers 3
scoreboard players set @p[score_ZHSPlayers_min=5,score_ZHSHandler_min=1] ZHSPlayers 4
scoreboard players set @p[score_ZHSHandler_min=1] ZHSHandler 0